﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="CreateEdit.aspx.cs" Inherits="School_CourseStudent_CreateEdit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <style type="text/css">
        .modalPopup
        {
            background-color: #fff;
            border-width: 3px;
            border-style: solid;
            border-color: Gray;
            padding: 3px;
            min-height: 400px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:UpdatePanel runat="server" ID="uplMain" UpdateMode="Conditional">
        <ContentTemplate>
            <h3>
                Create/Edit</h3>
            <hr />
            <div>
                <asp:ValidationSummary ID="vsCourseStudent" ValidationGroup="CourseStudent" runat="server"
                    BackColor="#FFCCFF" BorderStyle="Solid" BorderWidth="1px" ForeColor="#FF3300"
                    ShowMessageBox="True" />
            </div>
            <asp:HiddenField ID="hidCourseStudentId" runat="server" Value="-1" />
            <asp:HiddenField ID="hidCompanyId" runat="server" Value="-1" />
            <asp:Label runat="server" ID="lblCompany" Font-Size="Large" Font-Bold="true" /><br />
            <table>
                <tr>
                    <td>
                        Course Deatail
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlCourseDetailList" Width="350px" runat="server" OnSelectedIndexChanged="ddlCourseDetailList_SelectedIndexChanged"
                            AutoPostBack="True">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="rfvCourseStudentName0" runat="server" ErrorMessage="Course detail is required!"
                            ControlToValidate="ddlCourseDetailList" Text="*" ValidationGroup="CourseStudent"
                            ForeColor="#FF3300" InitialValue="-1"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td colspan="5">
                        <asp:Label ID="lblCourseDetail" runat="server" Text=""></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        Student
                    </td>
                    <td>
                        <asp:Panel runat="server" ID="pnlStudentNameSearch" DefaultButton="btnSearchStudentEnter">
                            <asp:TextBox runat="server" ID="txtStudentName" Width="350px" OnTextChanged="txtStudentName_TextChanged"
                                AutoPostBack="true" />
                            <asp:RequiredFieldValidator ID="rfvStudent" runat="server" ErrorMessage="Student is required!"
                                ControlToValidate="txtStudentName" Text="*" ValidationGroup="CourseStudent" ForeColor="#FF3300"></asp:RequiredFieldValidator>
                            <asp:HiddenField runat="server" ID="hidStudentProfileID" />
                            <asp:Button runat="server" ID="btnSearchStudent" Text="Search" OnClick="btnSearchStudent_Click" />
                            <asp:Button runat="server" ID="btnSearchStudentEnter" Style="display: none" Text="Search"
                                OnClick="btnSearchStudentEnter_Click" />
                        </asp:Panel>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td colspan="4">
                        <asp:Label ID="lblMessage" Font-Bold="true" ForeColor="Red" runat="server" Text=""></asp:Label>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        Remark:
                    </td>
                    <td colspan="4">
                        <asp:TextBox runat="server" ID="txtRemark" MaxLength="2000" Width="520px" AutoCompleteType="DisplayName"
                            Rows="4" TextMode="MultiLine" />
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <asp:Button ID="btnSubmit" ValidationGroup="CourseStudent" CausesValidation="true"
                            runat="server" Text="Submit" OnClick="btnSubmit_Click" />
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:Button runat="server" ID="btnHiddenStudentModalPopup" Style="display: none" />
    <ajaxToolkit:ModalPopupExtender runat="server" BehaviorID="studentSearchPopupBehavior"
        ID="mpexStudentSearch" CancelControlID="hideStudentSearchModalPopupClientButton"
        TargetControlID="btnHiddenStudentModalPopup" PopupControlID="pnlStudentSearch"
        RepositionMode="RepositionOnWindowScroll" DropShadow="true" BackgroundCssClass="modalBackground"
        PopupDragHandleControlID="pnlDragStudentSearch" />
    <asp:Panel ID="pnlStudentSearch" CssClass="modalPopup" runat="server" DefaultButton="btnSearchStudentNow"
        Style="display: none;">
        <asp:Panel runat="server" ID="pnlDragStudentSearch" Style="cursor: move; background-color: #DDDDDD;
            border: solid 1px Gray; color: Black; text-align: center;">
            Search Student<a href="#" style="float: right;" id="hideStudentSearchModalPopupClientButton">
                Close [X]</a>
        </asp:Panel>
        <asp:UpdatePanel runat="server" ID="uplStudentSearch" UpdateMode="Conditional">
            <ContentTemplate>
                <table>
                    <tr>
                        <td>
                            Name:
                        </td>
                        <td colspan="3">
                            <asp:TextBox runat="server" ID="txtStudentNameSearch" MaxLength="50" Width="200px"></asp:TextBox>
                            <asp:Button runat="server" ID="btnSearchStudentNow" Text="Refresh" OnClick="btnSearchStudentNow_Click" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <asp:GridView ID="gvStudent" runat="server" AutoGenerateColumns="False" DataKeyNames="Id"
                                DataSourceID="sqlDSStudentSearch" CellPadding="4" ForeColor="#333333" GridLines="None"
                                OnSelectedIndexChanged="gvStudent_SelectedIndexChanged" OnRowCommand="gvStudent_RowCommand"
                                OnRowDataBound="gvStudent_RowDataBound">
                                <AlternatingRowStyle BackColor="White" />
                                <Columns>
                                    <asp:ButtonField Text="SingleClick" CommandName="SingleClick" Visible="false" />
                                    <asp:ButtonField Text="DoubleClick" CommandName="DoubleClick" Visible="false" />
                                    <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                                        SortExpression="Id" Visible="false" />
                                    <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
                                    <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
                                    <asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
                                    <asp:BoundField DataField="DOB" HeaderText="DOB" SortExpression="DOB" />
                                    <asp:BoundField DataField="NRIC" HeaderText="NRIC" SortExpression="NRIC" />
                                </Columns>
                                <EmptyDataTemplate>
                                    No student found.
                                </EmptyDataTemplate>
                                <EditRowStyle BackColor="#2461BF" />
                                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                <RowStyle BackColor="#EFF3FB" />
                                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                <SortedAscendingCellStyle BackColor="#F5F7FB" />
                                <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                                <SortedDescendingCellStyle BackColor="#E9EBEF" />
                                <SortedDescendingHeaderStyle BackColor="#4870BE" />
                            </asp:GridView>
                            <asp:SqlDataSource ID="sqlDSStudentSearch" runat="server" ConnectionString="<%$ ConnectionStrings:DB2ConnectionString %>"
                                SelectCommand="usp_StudentProfileSearch" SelectCommandType="StoredProcedure">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="txtStudentNameSearch" Name="Name" PropertyName="Text"
                                        Type="String" DefaultValue="%" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
    <script type="text/javascript">
        //        function pageLoad() {
        //            $addHandler($get("btnStudentSearch"), 'click', showStudentSearchModalPopupViaClient);
        //            $addHandler($get("hideStudentSearchModalPopupClientButton"), 'click', hideStudentSearchModalPopupViaClient);
        //        }

        //        function showStudentSearchModalPopupViaClient(ev) {
        //            ev.preventDefault();
        //            var modalPopupBehavior = $find('studentSearchPopupBehavior');
        //            modalPopupBehavior.show();
        //        }

        //        function hideStudentSearchModalPopupViaClient(ev) {
        //            ev.preventDefault();
        //            var modalPopupBehavior = $find('studentSearchPopupBehavior');
        //            modalPopupBehavior.hide();
        //        }
    </script>
</asp:Content>
